package com.example.UserConsumer.RestController;

import com.example.UserConsumer.Entity.User;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class UserServerRegistryHystrixtFallbackFactory implements FallbackFactory<UserFeignClient> {

    private static final Logger logger = LoggerFactory.getLogger(UserServerRegistryHystrixtFallbackFactory.class);
    @Override
    public UserFeignClient create(Throwable cause) {
        UserServerRegistryHystrixtFallbackFactory.logger.info("fallback reason was: {} " ,cause.getMessage());

        return new UserFeignClient()
        {
            @Override
            public User FindUserById(String id)
            {
                User user = new User();
                user.setAge(999);
                user.setAdress("379753498@qq.com");
                user.setName("Testdev This is UserServerRegistryHystrixtFallback CLass retrun ");
                user.setQQ("379753498");
                user.setSex("man");
                return user;
            }
        };
    }



}




